import request from '@/utils/request'

export async function getRoleListApi(params) {
  var resp = await request({
    url: '/rbac/role/',
    method: 'get',
    params
  })
  return resp
}

export async function updateRoleListApi(id, data) {
  var resp = await request({
    url: '/rbac/role/' + id + '/',
    method: 'put',
    data
  })
  return resp
}

export async function createRoleListApi(data) {
  var resp = await request({
    url: '/rbac/role/',
    method: 'post',
    data
  })
  return resp
}

export async function deleteRoleListApi(id) {
  var resp = await request({
    url: '/rbac/role/' + id + '/',
    method: 'delete'
  })
  return resp
}

export async function getUserListApi(params) {
  var resp = await request({
    url: '/account/list/',
    method: 'get',
    params
  })
  return resp
}

export async function createUserApi(data) {
  var resp = await request({
    url: '/account/list/',
    method: 'post',
    data
  })
  return resp
}

export async function updateUserApi(id, data) {
  var resp = await request({
    url: '/account/list/' + id + '/',
    method: 'put',
    data
  })
  return resp
}

export async function deleteUserApi(id) {
  var resp = await request({
    url: '/account/list/' + id + '/',
    method: 'delete'
  })
  return resp
}

export async function getRoleMenuApi(params) {
  var resp = await request({
    url: '/rbac/role_menu_authorize/',
    method: 'get',
    params
  })
  return resp
}

export async function updateRoleMenuApi(data) {
  var resp = await request({
    url: '/rbac/role_menu_authorize/',
    method: 'post',
    data
  })
  return resp
}

export async function resetPasswordApi(data) {
  var resp = await request({
    url: '/account/reset_password/',
    method: 'post',
    data
  })
  return resp
}

export async function roleAssignUserApi(params) {
  var resp = await request({
    url: '/rbac/role_assign_user/',
    method: 'get',
    params
  })
  return resp
}

export async function updateRoleAssignUserApi(data) {
  var resp = await request({
    url: '/rbac/role_assign_user/',
    method: 'post',
    data
  })
  return resp
}

export async function getMenuStructureTreeApi() {
  var resp = await request({
    url: '/rbac/get_menu_structure_tree/',
    method: 'get'
  })
  return resp
}

export async function getMenuSensitiveFieldAuthorizeApi(params) {
  var resp = await request({
    url: '/rbac/menu_sensitive_field_authorize/',
    method: 'get',
    params
  })
  return resp
}

export async function updateMenuSensitiveFieldAuthorizeApi(data) {
  var resp = await request({
    url: '/rbac/menu_sensitive_field_authorize/',
    method: 'post',
    data
  })
  return resp
}

export async function updateMenuSensitiveFieldBatchAuthorizeApi(data) {
  var resp = await request({
    url: '/rbac/menu_sensitive_field_batch_authorize/',
    method: 'post',
    data
  })
  return resp
}

